using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using OracleInternal.Common;

namespace OracleInternal.Network
{
	internal class AddressResolution : IEnumerable
	{
		private NVPair m_dlist;

		private const int length_of_alias_prefix = 6;

		internal const int DEFAULT_DATABASE_PORT = 1521;

		internal static char[] colonORslash;

		internal static string POOLED_SERVER;

		internal static string SHARED_SERVER;

		internal static string DEDICATED_SERVER;

		internal static string DEFAULT_CONNECT_PROTOCOL;

		internal static List<string> All_PROTOCOLS;

		internal static string DEFAULT_CONNECT_PROTOCOL_LOWERCASE;

		internal static string SSL_CONNECT_PROTOCOL;

		internal static string SSL_CONNECT_PROTOCOL_LOWERCASE;

		internal static string ANO_CONNECT_PROTOCOL;

		internal static string ANO_CONNECT_PROTOCOL_LOWERCASE;

		internal static string WEBSOCK_CONNECT_PROTOCOL;

		internal static string WEBSOCK_CONNECT_PROTOCOL_LOWERCASE;

		internal static string WEBSOCK_SECURE_CONNECT_PROTOCOL;

		internal static string WEBSOCK_SECURE_CONNECT_PROTOCOL_LOWERCASE;

		internal static string BEGIN_DBL_SLASH;

		internal static string OPENING_SQUARE_BRACE;

		internal static string BEG_CID;

		internal static string BEG_USER;

		internal static string BEG_ADDR;

		internal static string BEG_HOST;

		internal static string BEG_PORT;

		internal static string BEG_DESC;

		internal static string BEG_CCLS;

		internal static string BEG_PURE;

		internal static string BEG_STAG;

		internal static string BEG_SRVR;

		internal static string BEG_INST;

		internal static string BEG_SKEY;

		internal static string BEG_SSKEY;

		internal static string BEG_PROGRAM;

		internal static string BEG_CONDATA;

		internal static string BEG_CONDATA_SVC;

		internal static string END_THREE_BRACES;

		internal static string END_TWO_BRACES;

		internal static string END_ONE_BRACE;

		internal static string ALIAS;

		internal static string CID;

		internal static string SID;

		internal static string INSTANCE_NAME;

		internal static string SERVICE_NAME;

		internal static string SERVER;

		internal static string PROTOCOL;

		internal static string ADDRESS;

		internal static string CONNECT_DATA;

		internal static string ADDRESS_LIST;

		internal static string HOST;

		internal static string PORT;

		internal static string IP;

		internal static string SDU;

		internal static string TDU;

		internal static string SBS;

		internal static string RBS;

		internal static string SendBufSize;

		internal static string RecvBufSize;

		internal static string DESCRIPTION;

		internal static string SOURCE_ROUTE;

		internal static string DESCRIPTION_LIST;

		internal static string RETRY_COUNT;

		internal static string RETRY_DELAY;

		internal static string TRANSPORT_CONNECT_TO;

		internal static string SECURITY;

		internal static string SSL_VERSION;

		internal static string WALLETDIR;

		internal static string WALLETLOC;

		internal static string SSLServerDN;

		internal static string SSLServerDNMatch;

		internal static string READONLY_CHUNK_OK;

		internal static string EncryptionClient;

		internal static string EncryptionTypesClient;

		internal static string CryptoChecksumClient;

		internal static string CryptoChecksumTypesClient;

		internal static string SID_ENV;

		internal static string HTTPS_PROXY;

		internal static string HTTPS_PROXY_PORT;

		internal static string WEBSOCK_URI;

		internal static string DEFAULT_ADDRESS;

		internal static string HOSTNAME;

		internal static string USERNAME;

		internal static string PROGRAMNAME;

		internal static NVPair nvp_CID;

		internal static string val_CID;

		internal static string ful_CID;

		internal bool connection_revised;

		internal bool connection_redirected;

		internal bool useAddrResConnectString;

		internal string m_tnsAddress;

		private NVPair m_desc;

		private string m_instanceName;

		private string m_ShardingKey;

		private string m_SuperShardingKey;

		internal ConnectionOption m_ConnectionOption;

		private SqlNetOraConfig m_SNOConfig;

		private Hashtable m_ObCfgHT;

		private Hashtable m_ObTnsHT;

		private Hashtable m_obLdpHT;

		private string m_ServerIs;

		private static SqlNetOraConfig m_SNOConfig_static;

		private bool DynNamingAdapterList;

		private bool tnsnames_ora_resolved;

		private static char NLNVBEGDE;

		private static char NLNVENDDE;

		private static char NLNVASNOP;

		private static char NLNVPTHDE;

		private static char NLNVESCAP;

		private static char NLNVQUOTE;

		private static char NLNVSQUOTE;

		private static TNSNames m_TNSNames;

		private static LDAP m_LDAP;

		private static List<INamingAdapter> _NamingAdapters;

		private List<INamingAdapter> _NamingAdaptersDyn;

		private static INamingAdapter _DataSourcesAdapter;

		private static char[] NCS;

		private static char[] reservedNCS;

		internal static byte[] ValidChars;

		private static void SetupValidChars()
		{
			for (int i = 0; i < NCS.Length; i++)
			{
				ValidChars[NCS[i]] = 1;
			}
			for (int i = 0; i < reservedNCS.Length; i++)
			{
				ValidChars[reservedNCS[i]] = 0;
			}
		}

		private static string VetCIDValue(string CIDValue)
		{
			StringBuilder stringBuilder;
			try
			{
				stringBuilder = new StringBuilder(CIDValue);
				for (int i = 0; i < stringBuilder.Length; i++)
				{
					if (ValidChars[stringBuilder[i]] == 0)
					{
						stringBuilder[i] = '?';
					}
				}
			}
			catch (Exception)
			{
				return "";
			}
			return stringBuilder.ToString();
		}

		static AddressResolution()
		{
			colonORslash = new char[2]
			{
				'/',
				':'
			};
			POOLED_SERVER = "POOLED";
			SHARED_SERVER = "SHARED";
			DEDICATED_SERVER = "DEDICATED";
			DEFAULT_CONNECT_PROTOCOL = "TCP";
			All_PROTOCOLS = new List<string>
			{
				"tcp",
				"tcps",
				"ws",
				"wss"
			};
			DEFAULT_CONNECT_PROTOCOL_LOWERCASE = "tcp";
			SSL_CONNECT_PROTOCOL = "TCPS";
			SSL_CONNECT_PROTOCOL_LOWERCASE = "tcps";
			ANO_CONNECT_PROTOCOL = "ANO";
			ANO_CONNECT_PROTOCOL_LOWERCASE = "ano";
			WEBSOCK_CONNECT_PROTOCOL = "WS";
			WEBSOCK_CONNECT_PROTOCOL_LOWERCASE = "ws";
			WEBSOCK_SECURE_CONNECT_PROTOCOL = "WSS";
			WEBSOCK_SECURE_CONNECT_PROTOCOL_LOWERCASE = "wss";
			BEGIN_DBL_SLASH = "//";
			OPENING_SQUARE_BRACE = "[";
			BEG_CID = "(CID=";
			BEG_USER = ")(USER=";
			BEG_ADDR = "(ADDRESS=(PROTOCOL=";
			BEG_HOST = ")(HOST=";
			BEG_PORT = ")(PORT=";
			BEG_DESC = "(DESCRIPTION=";
			BEG_CCLS = "(POOL_CONNECTION_CLASS=";
			BEG_PURE = "(POOL_PURITY=";
			BEG_STAG = "(SERVICE_TAG=";
			BEG_SRVR = "(SERVER=";
			BEG_INST = "(INSTANCE_NAME=";
			BEG_SKEY = "(SHARDING_KEY_B64=";
			BEG_SSKEY = "(SUPER_SHARDING_KEY_B64=";
			BEG_PROGRAM = "(PROGRAM=";
			BEG_CONDATA = "(CONNECT_DATA=";
			BEG_CONDATA_SVC = "(CONNECT_DATA=(SERVICE_NAME=";
			END_THREE_BRACES = ")))";
			END_TWO_BRACES = "))";
			END_ONE_BRACE = ")";
			ALIAS = "alias=";
			CID = "CID";
			SID = "SID";
			INSTANCE_NAME = "INSTANCE_NAME";
			SERVICE_NAME = "SERVICE_NAME";
			SERVER = "SERVER";
			PROTOCOL = "PROTOCOL";
			ADDRESS = "ADDRESS";
			CONNECT_DATA = "CONNECT_DATA";
			ADDRESS_LIST = "ADDRESS_LIST";
			HOST = "HOST";
			PORT = "PORT";
			IP = "IP";
			SDU = "SDU";
			TDU = "TDU";
			SBS = "SBS";
			RBS = "RBS";
			SendBufSize = "SEND_BUF_SIZE";
			RecvBufSize = "RECV_BUF_SIZE";
			DESCRIPTION = "DESCRIPTION";
			SOURCE_ROUTE = "SOURCE_ROUTE";
			DESCRIPTION_LIST = "DESCRIPTION_LIST";
			RETRY_COUNT = "RETRY_COUNT";
			RETRY_DELAY = "RETRY_DELAY";
			TRANSPORT_CONNECT_TO = "TRANSPORT_CONNECT_TIMEOUT";
			SECURITY = "SECURITY";
			SSL_VERSION = "SSL_VERSION";
			WALLETDIR = "MY_WALLET_DIRECTORY";
			WALLETLOC = "WALLET_LOCATION";
			SSLServerDN = "SSL_SERVER_CERT_DN";
			SSLServerDNMatch = "SSL_SERVER_DN_MATCH";
			READONLY_CHUNK_OK = "READONLY_CHUNK_OK";
			EncryptionClient = "ENCRYPTION_CLIENT";
			EncryptionTypesClient = "ENCRYPTION_TYPES_CLIENT";
			CryptoChecksumClient = "CRYPTO_CHECKSUM_CLIENT";
			CryptoChecksumTypesClient = "CRYPTO_CHECKSUM_TYPES_CLIENT";
			SID_ENV = "ORACLE_SID";
			HTTPS_PROXY = "HTTPS_PROXY";
			HTTPS_PROXY_PORT = "HTTPS_PROXY_PORT";
			WEBSOCK_URI = "WEBSOCK_URI";
			DEFAULT_ADDRESS = "(Description=(Address=(Protocol=tcp)(IP=loopback)(port=1521))(CONNECT_DATA=(SID=";
			m_SNOConfig_static = null;
			NLNVBEGDE = '(';
			NLNVENDDE = ')';
			NLNVASNOP = '=';
			NLNVPTHDE = '/';
			NLNVESCAP = '\\';
			NLNVQUOTE = '"';
			NLNVSQUOTE = '\'';
			m_TNSNames = new TNSNames();
			m_LDAP = null;
			_NamingAdapters = new List<INamingAdapter>(10);
			_DataSourcesAdapter = null;
			NCS = new char[87]
			{
				'A',
				'B',
				'C',
				'D',
				'E',
				'F',
				'G',
				'H',
				'I',
				'J',
				'K',
				'L',
				'M',
				'N',
				'O',
				'P',
				'Q',
				'R',
				'S',
				'T',
				'U',
				'V',
				'W',
				'X',
				'Y',
				'Z',
				'a',
				'b',
				'c',
				'd',
				'e',
				'f',
				'g',
				'h',
				'i',
				'j',
				'k',
				'l',
				'm',
				'n',
				'o',
				'p',
				'q',
				'r',
				's',
				't',
				'u',
				'v',
				'w',
				'x',
				'y',
				'z',
				'0',
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9',
				'0',
				'(',
				')',
				'<',
				'>',
				'/',
				'\\',
				',',
				'.',
				':',
				';',
				'\'',
				'"',
				'=',
				'-',
				'_',
				'$',
				'+',
				'*',
				'#',
				'&',
				'!',
				'%',
				'?',
				'@'
			};
			reservedNCS = new char[3]
			{
				NLNVBEGDE,
				NLNVENDDE,
				NLNVASNOP
			};
			ValidChars = new byte[256];
			m_SNOConfig_static = new SqlNetOraConfig(ConfigBaseClass.m_configParameters);
			string[] namesDirectoryPath = m_SNOConfig_static.NamesDirectoryPath;
			_NamingAdapters.Add(_DataSourcesAdapter = new DataSources());
			if (namesDirectoryPath != null)
			{
				string[] array = namesDirectoryPath;
				for (int i = 0; i < array.Length; i++)
				{
					switch (array[i].ToUpperInvariant())
					{
					case "TNSNAMES":
						_NamingAdapters.Add(m_TNSNames);
						break;
					case "LDAP":
						if (m_LDAP == null)
						{
							m_LDAP = new LDAP();
						}
						_NamingAdapters.Add(m_LDAP);
						break;
					case "EZCONNECT":
					case "HOSTNAME":
						_NamingAdapters.Add(new EZConnect());
						break;
					}
				}
			}
			SetupValidChars();
			try
			{
				PROGRAMNAME = Environment.GetCommandLineArgs()[0];
			}
			catch (Exception)
			{
			}
			if (PROGRAMNAME == null)
			{
				PROGRAMNAME = "";
			}
			try
			{
				HOSTNAME = Dns.GetHostName();
			}
			catch (Exception)
			{
			}
			if (HOSTNAME == null && (HOSTNAME = Environment.MachineName) == null)
			{
				HOSTNAME = "";
			}
			if ((USERNAME = Environment.UserName) == null)
			{
				USERNAME = "";
			}
			PROGRAMNAME = VetCIDValue(PROGRAMNAME);
			USERNAME = VetCIDValue(USERNAME);
			HOSTNAME = VetCIDValue(HOSTNAME);
			val_CID = BEG_PROGRAM + PROGRAMNAME + BEG_HOST + HOSTNAME + BEG_USER + USERNAME + END_ONE_BRACE;
			try
			{
				nvp_CID = new NVPair(CID, val_CID);
			}
			catch (Exception)
			{
			}
			ful_CID = BEG_CID + BEG_PROGRAM + PROGRAMNAME + BEG_HOST + HOSTNAME + BEG_USER + USERNAME + END_TWO_BRACES;
		}

		internal static void SetNewTNSHT(Hashtable HT)
		{
			m_TNSNames.SetNewHT(HT);
		}

		internal static void SetNewLDAP(Hashtable SQLNetHT, Hashtable LdapHT)
		{
			for (int i = 0; i < _NamingAdapters.Count; i++)
			{
				if (_NamingAdapters[i].ID == "LDAP")
				{
					_NamingAdapters[i] = (m_LDAP = new LDAP(new SqlNetOraConfig(SQLNetHT), LdapHT));
				}
			}
		}

		internal static void SetNewNDP(string[] adapters)
		{
			if (adapters == null)
			{
				return;
			}
			_NamingAdapters = new List<INamingAdapter>(10);
			_NamingAdapters.Add(_DataSourcesAdapter);
			for (int i = 0; i < adapters.Length; i++)
			{
				switch (adapters[i].ToUpperInvariant())
				{
				case "TNSNAMES":
					_NamingAdapters.Add(m_TNSNames);
					break;
				case "LDAP":
					if (m_LDAP == null)
					{
						m_LDAP = new LDAP();
					}
					_NamingAdapters.Add(m_LDAP);
					break;
				case "EZCONNECT":
				case "HOSTNAME":
					_NamingAdapters.Add(new EZConnect());
					break;
				}
			}
		}

		internal AddressResolution(string TNSAlias, SqlNetOraConfig SNOConfig, Hashtable ObTnsHT = null, Hashtable ObLdpHT = null, string instanceName = null, ConnectionOption CO = null, string ShardingKeyB64 = null, string SuperShardingKeyB64 = null, string ServerIs = null)
		{
			m_ObTnsHT = ObTnsHT;
			m_obLdpHT = ObLdpHT;
			m_ServerIs = ServerIs;
			m_SNOConfig = SNOConfig;
			m_instanceName = instanceName;
			m_ShardingKey = ShardingKeyB64;
			m_SuperShardingKey = SuperShardingKeyB64;
			if (!string.IsNullOrEmpty(TNSAlias))
			{
				TNSAlias = TNSAlias.Replace("\"", "");
			}
			if (CO != null)
			{
				m_ConnectionOption = CO.Clone();
				m_tnsAddress = CO.ConnectData;
				if ((!string.IsNullOrEmpty(m_tnsAddress) && (!string.IsNullOrEmpty(instanceName) || !string.IsNullOrEmpty(ShardingKeyB64) || !string.IsNullOrEmpty(SuperShardingKeyB64))) || !string.IsNullOrEmpty(ServerIs))
				{
					NVPair nVPair = NVFactory.CreateNVPair(m_tnsAddress);
					addInstance(nVPair, CO, addCID: false);
					m_tnsAddress = nVPair.ToString();
					useAddrResConnectString = true;
				}
			}
			else
			{
				m_tnsAddress = TNSAlias;
				m_instanceName = instanceName;
				CheckNewList();
				bool flag = ObTnsHT != null;
				bool flag2 = ObLdpHT != null || SNOConfig != null;
				if ((flag || flag2) && !DynNamingAdapterList)
				{
					_NamingAdaptersDyn = new List<INamingAdapter>(_NamingAdapters);
					for (int i = 0; i < _NamingAdaptersDyn.Count; i++)
					{
						if (flag && _NamingAdaptersDyn[i].ID == "TNSNames")
						{
							_NamingAdaptersDyn[i] = new TNSNames();
							((TNSNames)_NamingAdaptersDyn[i]).SetNewHT(ObTnsHT);
						}
						else if (flag2 && _NamingAdaptersDyn[i].ID == "LDAP")
						{
							_NamingAdaptersDyn[i] = new LDAP(SNOConfig, ObLdpHT);
						}
					}
				}
				m_tnsAddress = Resolve(TNSAlias, out m_ConnectionOption, instanceName, ServerIs);
			}
			if (string.IsNullOrEmpty(m_tnsAddress))
			{
				throw new NetworkException(12154);
			}
			m_tnsAddress = m_tnsAddress.Replace("\"", "");
		}

		public static void RefreshNamingAdapters()
		{
			foreach (INamingAdapter namingAdapter in _NamingAdapters)
			{
				namingAdapter.Refresh();
			}
		}

		public static IEnumerable NamingAdapters()
		{
			foreach (INamingAdapter namingAdapter in _NamingAdapters)
			{
				yield return namingAdapter;
			}
		}

		public static IEnumerable NamingAdapterMaps()
		{
			foreach (INamingAdapter namingAdapter in _NamingAdapters)
			{
				yield return namingAdapter.Map;
			}
		}

		private void addInstance(NVPair desc, ConnectionOption co, bool addCID = true)
		{
			NVPair nVPair = NVNavigator.FindNVPair(desc, CONNECT_DATA);
			bool flag = !string.IsNullOrEmpty(m_instanceName);
			bool flag2 = false;
			bool flag3 = false;
			if (nVPair == null)
			{
				desc.AddListElement(NVFactory.CreateNVPair(BEG_CONDATA + END_ONE_BRACE));
				nVPair = NVNavigator.FindNVPair(desc, CONNECT_DATA);
			}
			else
			{
				for (int i = 0; i < nVPair.ListSize; i++)
				{
					NVPair listElement = nVPair.GetListElement(i);
					if (string.Equals(listElement.Name, CID, StringComparison.InvariantCultureIgnoreCase) && addCID)
					{
						nVPair.RemoveListElement(i);
					}
					if (string.Equals(listElement.Name, SERVICE_NAME, StringComparison.InvariantCultureIgnoreCase))
					{
						flag2 = true;
						co.ServiceName = listElement.Atom;
					}
					if (string.Equals(listElement.Name, INSTANCE_NAME, StringComparison.InvariantCultureIgnoreCase))
					{
						flag3 = true;
						co.InstanceName = listElement.Atom;
					}
					if (string.Equals(listElement.Name, SERVER, StringComparison.InvariantCultureIgnoreCase))
					{
						if (!string.IsNullOrEmpty(m_ServerIs))
						{
							co.Server = m_ServerIs;
							nVPair.RemoveListElement(i);
						}
						else
						{
							co.Server = listElement.Atom;
						}
					}
					if (string.Equals(listElement.Name, READONLY_CHUNK_OK, StringComparison.InvariantCultureIgnoreCase))
					{
						co.READONLY_CHUNK_OK = SqlNetOraConfig.ParamValueIsTrue(listElement.Atom);
					}
				}
				if (flag && flag2 && !flag3)
				{
					nVPair.AddListElement(NVFactory.CreateNVPair(BEG_INST + m_instanceName + END_ONE_BRACE));
				}
			}
			if (nVPair == null)
			{
				throw new NetworkException(12550);
			}
			if (!string.IsNullOrEmpty(m_ShardingKey))
			{
				nVPair.AddListElement(NVFactory.CreateNVPair(BEG_SKEY + m_ShardingKey + END_ONE_BRACE));
			}
			if (!string.IsNullOrEmpty(m_SuperShardingKey))
			{
				nVPair.AddListElement(NVFactory.CreateNVPair(BEG_SSKEY + m_SuperShardingKey + END_ONE_BRACE));
			}
			if (!string.IsNullOrEmpty(m_ServerIs))
			{
				nVPair.AddListElement(NVFactory.CreateNVPair(BEG_SRVR + m_ServerIs + END_ONE_BRACE));
			}
			if (!addCID)
			{
				return;
			}
			try
			{
				if (nvp_CID != null)
				{
					nVPair.AddListElement(nvp_CID);
				}
			}
			catch (Exception)
			{
			}
		}

		private void HandleAddress(NVPair cnvp, NVPair desc, ref int cur, ref int end)
		{
			NVPair nVPair = null;
			NVPair nVPair2 = cnvp;
			bool flag = false;
			IPAddress[] array = null;
			try
			{
				nVPair = NVNavigator.FindNVPair(nVPair2, HOST);
			}
			catch (Exception)
			{
			}
			string atom;
			if (nVPair == null || string.IsNullOrEmpty(atom = nVPair.Atom))
			{
				cur++;
				return;
			}
			if (BadIPCache.BadHost(atom).Value)
			{
				IP = atom;
				flag = true;
			}
			else
			{
				try
				{
					array = Dns.GetHostAddresses(atom);
				}
				catch (Exception)
				{
				}
				if (array == null || array.Length == 0)
				{
					IP = atom;
					BadIPCache.Insert(atom, host: true);
					flag = true;
				}
				else
				{
					nVPair.Atom = (IP = array[0].ToString());
				}
			}
			if (BadIPCache.Bad(IP).Value || BadIPCache.BadHost(IP).Value)
			{
				desc.RemoveListElement(cur);
				desc.AddListElement(--end, nVPair2);
			}
			else
			{
				cur++;
			}
			if (flag)
			{
				return;
			}
			for (int i = 1; i < array.Length; i++)
			{
				IP = array[i].ToString();
				nVPair2 = cnvp.Clone();
				if ((nVPair = NVNavigator.FindNVPair(nVPair2, HOST)) != null)
				{
					nVPair.Atom = IP;
				}
				int after;
				if (BadIPCache.Bad(IP).Value)
				{
					after = end;
				}
				else
				{
					after = cur++;
					end++;
				}
				desc.AddListElement(after, nVPair2);
			}
		}

		private void HandleList(NVPair list)
		{
			if (list == null || list.ListSize == 0)
			{
				return;
			}
			int cur = 0;
			int end = list.ListSize;
			while (cur < end)
			{
				NVPair listElement = list.GetListElement(cur);
				if (string.Equals(listElement.Name, ADDRESS, StringComparison.InvariantCultureIgnoreCase))
				{
					HandleAddress(listElement, list, ref cur, ref end);
				}
				else if (string.Equals(listElement.Name, ADDRESS_LIST, StringComparison.InvariantCultureIgnoreCase))
				{
					HandleList(listElement);
					cur++;
				}
				else
				{
					cur++;
				}
			}
		}

		private void CheckBadIP(NVPair desc)
		{
			HandleList(desc);
		}

		private bool DeleteAddress_and_AL(NVPair list)
		{
			bool result = true;
			if (list == null || list.ListSize == 0)
			{
				return result;
			}
			int num = 0;
			_ = list.ListSize;
			while (num < list.ListSize)
			{
				NVPair listElement = list.GetListElement(num);
				if (string.Equals(listElement.Name, ADDRESS, StringComparison.InvariantCultureIgnoreCase))
				{
					list.RemoveListElement(num);
				}
				else if (string.Equals(listElement.Name, ADDRESS_LIST, StringComparison.InvariantCultureIgnoreCase))
				{
					list.RemoveListElement(num);
				}
				else if (string.Equals(listElement.Name, "FAILOVER", StringComparison.InvariantCultureIgnoreCase))
				{
					result = SqlNetOraConfig.ParamValueIsTrue(listElement.Atom);
					num++;
				}
				else
				{
					num++;
				}
			}
			return result;
		}

		private static bool GetFAilover(NVPair NVP)
		{
			bool result = true;
			if (NVP != null)
			{
				NVPair nVPair = NVNavigator.FindNVPair(NVP, "FAILOVER");
				if (nVPair != null && nVPair.Atom != null)
				{
					result = SqlNetOraConfig.ParamValueIsTrue(nVPair.Atom);
				}
			}
			return result;
		}

		public IEnumerator GetEnumerator()
		{
			if (m_tnsAddress == null || m_tnsAddress.Length == 0)
			{
				throw new NetworkException(12154);
			}
			int retries;
			int delay;
			if (m_ConnectionOption != null)
			{
				List<EZConnect.HostPort> HostPortPairs = m_ConnectionOption.HostPortPairs;
				if (HostPortPairs == null)
				{
					throw new NetworkException(12550);
				}
				retries = m_ConnectionOption.Retries;
				delay = m_ConnectionOption.RetryDelay;
				do
				{
					for (int j = HostPortPairs.Count - 1; j >= 0; j--)
					{
						EZConnect.HostPort hostPort = HostPortPairs[j];
						m_ConnectionOption.Host = hostPort.host;
						m_ConnectionOption.Port = hostPort.port;
						yield return m_ConnectionOption;
					}
					if (delay > 0 && retries > 0)
					{
						Thread.Sleep(delay * 1000);
					}
				}
				while (retries-- > 0);
				yield break;
			}
			if (m_tnsAddress.StartsWith(ALIAS))
			{
				string tnsAddress = m_tnsAddress;
				m_tnsAddress = tnsAddress.Substring(tnsAddress.IndexOf(ALIAS) + 6, tnsAddress.Length - (tnsAddress.IndexOf(ALIAS) + 6));
			}
			NVPair nvp = NVFactory.CreateNVPair(m_tnsAddress);
			NVPair nVPair = NVNavigator.FindNVPairRecurse(nvp, DESCRIPTION_LIST);
			NVPair OrigDesc2;
			bool failover2;
			if (nVPair != null)
			{
				NVNavigator dlistNVN = new NVNavigator(nVPair);
				dlistNVN.SetFindString(DESCRIPTION);
				if ((m_desc = dlistNVN.FindNVPair()) == null)
				{
					throw new NetworkException(12550);
				}
				while (m_desc != null)
				{
					GetRetries(m_desc, out retries, out delay);
					OrigDesc2 = m_desc.Clone();
					failover2 = DeleteAddress_and_AL(OrigDesc2);
					do
					{
						CheckBadIP(m_desc);
						for (int j = 0; j < m_desc.ListSize; j++)
						{
							NVPair listElement = m_desc.GetListElement(j);
							if (string.Equals(listElement.Name, ADDRESS, StringComparison.InvariantCultureIgnoreCase))
							{
								yield return BuildCO(OrigDesc2, listElement);
								if (!failover2)
								{
									break;
								}
							}
							else
							{
								if (!string.Equals(listElement.Name, ADDRESS_LIST, StringComparison.InvariantCultureIgnoreCase))
								{
									continue;
								}
								bool failoverAL2 = GetFAilover(listElement);
								NVNavigator alNVN2 = new NVNavigator(listElement);
								alNVN2.SetFindString(ADDRESS);
								for (NVPair nVPair2 = alNVN2.FindNVPair(); nVPair2 != null; nVPair2 = alNVN2.FindNVPair())
								{
									yield return BuildCO(OrigDesc2, nVPair2);
									if (!failoverAL2)
									{
										break;
									}
								}
							}
						}
						if (delay > 0 && retries > 0)
						{
							Thread.Sleep(delay * 1000);
						}
					}
					while (retries-- > 0);
					m_desc = dlistNVN.FindNVPair();
				}
				yield break;
			}
			m_desc = NVNavigator.FindNVPairRecurse(nvp, DESCRIPTION);
			if (m_desc == null)
			{
				m_tnsAddress = BEG_DESC + BEG_CONDATA + END_ONE_BRACE + m_tnsAddress + END_ONE_BRACE;
				nvp = NVFactory.CreateNVPair(m_tnsAddress);
				m_desc = NVNavigator.FindNVPairRecurse(nvp, DESCRIPTION);
			}
			if (m_desc == null)
			{
				throw new NetworkException(12550);
			}
			GetRetries(m_desc, out retries, out delay);
			OrigDesc2 = m_desc.Clone();
			failover2 = DeleteAddress_and_AL(OrigDesc2);
			do
			{
				CheckBadIP(m_desc);
				for (int j = 0; j < m_desc.ListSize; j++)
				{
					NVPair listElement = m_desc.GetListElement(j);
					if (string.Equals(listElement.Name, ADDRESS, StringComparison.InvariantCultureIgnoreCase))
					{
						yield return BuildCO(OrigDesc2, listElement);
						if (!failover2)
						{
							break;
						}
					}
					else
					{
						if (!string.Equals(listElement.Name, ADDRESS_LIST, StringComparison.InvariantCultureIgnoreCase))
						{
							continue;
						}
						bool failoverAL2 = GetFAilover(listElement);
						NVNavigator alNVN2 = new NVNavigator(listElement);
						alNVN2.SetFindString(ADDRESS);
						for (NVPair nVPair2 = alNVN2.FindNVPair(); nVPair2 != null; nVPair2 = alNVN2.FindNVPair())
						{
							yield return BuildCO(OrigDesc2, nVPair2);
							if (!failoverAL2)
							{
								break;
							}
						}
					}
				}
				if (delay > 0 && retries > 0)
				{
					Thread.Sleep(delay * 1000);
				}
			}
			while (retries-- > 0);
		}

		private void GetRetries(NVPair m_desc, out int retries, out int delay)
		{
			retries = (delay = 0);
			NVPair nVPair;
			if ((nVPair = NVNavigator.FindNVPair(m_desc, RETRY_COUNT)) != null)
			{
				retries = int.Parse(nVPair.Atom);
				if ((nVPair = NVNavigator.FindNVPair(m_desc, RETRY_DELAY)) != null)
				{
					delay = int.Parse(nVPair.Atom);
				}
			}
		}

		private NVNavigator getAddressContainer(NVPair m_desc)
		{
			NVPair nVPair = NVNavigator.FindNVPair(m_desc, ADDRESS_LIST);
			if (nVPair != null)
			{
				return new NVNavigator(nVPair);
			}
			return new NVNavigator(m_desc);
		}

		internal string Resolve(string TNSAlias, out ConnectionOption CO, string instanceName = null, string ServerIs = null)
		{
			string text = null;
			CO = null;
			if (TNSAlias == null || TNSAlias.Length == 0)
			{
				string text2 = ConfigBaseClass.m_configParameters[SID_ENV] as string;
				if (string.IsNullOrEmpty(text2))
				{
					text2 = Environment.GetEnvironmentVariable(SID_ENV);
				}
				if (!string.IsNullOrEmpty(text2))
				{
					text = DEFAULT_ADDRESS + text2 + ")))";
				}
			}
			else
			{
				if (TNSAlias.Trim().IndexOf('(') != 0)
				{
					if (!string.IsNullOrEmpty(m_SNOConfig.NamesDefaultDomain) && TNSAlias.IndexOf(':') == -1 && TNSAlias.IndexOf('/') == -1)
					{
						int num = TNSAlias.IndexOf('.');
						if (num == -1)
						{
							TNSAlias = TNSAlias + "." + m_SNOConfig.NamesDefaultDomain;
						}
						else if (num == TNSAlias.Length - 1)
						{
							TNSAlias = TNSAlias.Substring(0, TNSAlias.Length - 1);
						}
					}
					{
						foreach (INamingAdapter item in (_NamingAdaptersDyn != null) ? _NamingAdaptersDyn : _NamingAdapters)
						{
							text = item.Resolve(TNSAlias, out CO, instanceName, ServerIs);
							if (text != null)
							{
								return text;
							}
						}
						return text;
					}
				}
				text = TNSAlias;
			}
			return text;
		}

		private void CheckNewList()
		{
			bool flag = m_SNOConfig != null && m_SNOConfig_static.m_ConfigHT != m_SNOConfig.m_ConfigHT;
			if (!flag)
			{
				return;
			}
			string[] namesDirectoryPath = m_SNOConfig_static.NamesDirectoryPath;
			string[] namesDirectoryPath2 = m_SNOConfig.NamesDirectoryPath;
			int num;
			bool flag2 = (num = namesDirectoryPath.Length) == namesDirectoryPath2.Length;
			if (flag2)
			{
				for (int i = 0; i < num && flag2; i++)
				{
					if (string.Compare(namesDirectoryPath[i], namesDirectoryPath2[i], StringComparison.InvariantCultureIgnoreCase) != 0)
					{
						flag2 = false;
					}
				}
			}
			if (flag2)
			{
				return;
			}
			DynNamingAdapterList = true;
			_NamingAdaptersDyn = new List<INamingAdapter>(10);
			_NamingAdaptersDyn.Add(_DataSourcesAdapter = new DataSources());
			string[] array = namesDirectoryPath2;
			for (int j = 0; j < array.Length; j++)
			{
				switch (array[j].ToUpperInvariant())
				{
				case "TNSNAMES":
				{
					TNSNames tNSNames;
					if (m_ObTnsHT != null)
					{
						tNSNames = new TNSNames();
						tNSNames.SetNewHT(m_ObTnsHT);
					}
					else
					{
						tNSNames = m_TNSNames;
					}
					_NamingAdaptersDyn.Add(tNSNames);
					break;
				}
				case "LDAP":
					if (m_obLdpHT != null || flag)
					{
						_NamingAdaptersDyn.Add(new LDAP(m_SNOConfig, m_obLdpHT));
					}
					else
					{
						_NamingAdaptersDyn.Add(m_LDAP = ((m_LDAP == null) ? new LDAP() : m_LDAP));
					}
					break;
				case "EZCONNECT":
				case "HOSTNAME":
					_NamingAdaptersDyn.Add(new EZConnect());
					break;
				}
			}
		}

		internal ConnectionOption ResolveConnectionString()
		{
			if (m_tnsAddress == null || m_tnsAddress.Length == 0)
			{
				throw new NetworkException(-6500);
			}
			if (m_ConnectionOption != null)
			{
				return m_ConnectionOption;
			}
			if (m_tnsAddress.IndexOf(')') == -1)
			{
				return ResolveSimple(m_tnsAddress);
			}
			return ResolveAddr(m_tnsAddress);
		}

		private string GetValue(string TNSdesc, ref int POS)
		{
			POS++;
			int num = TNSdesc.IndexOfAny(colonORslash, POS);
			if (num == -1)
			{
				num = TNSdesc.Length;
			}
			string result = TNSdesc.Substring(POS, num - POS);
			POS = num;
			return result;
		}

		private ConnectionOption ResolveSimple(string TNSdesc)
		{
			ConnectionOption connectionOption = new ConnectionOption();
			int num = 0;
			int num2 = 0;
			connectionOption.Protocol = DEFAULT_CONNECT_PROTOCOL;
			connectionOption.Server = null;
			if (TNSdesc.StartsWith(BEGIN_DBL_SLASH))
			{
				num2 = 2;
			}
			if (TNSdesc[num2] == '[')
			{
				num2++;
				num = TNSdesc.IndexOf(']', num2);
				if (num == -1)
				{
					throw new NetworkException(12550);
				}
				connectionOption.Host = TNSdesc.Substring(num2, num - num2);
				num2 = num + 1;
			}
			else
			{
				num = TNSdesc.IndexOfAny(colonORslash, num2);
				if (num == -1)
				{
					num = TNSdesc.Length - 1;
				}
				connectionOption.Host = TNSdesc.Substring(num2, num - num2);
				num2 = num;
			}
			if (num2 < TNSdesc.Length)
			{
				if (TNSdesc[num2] == ':')
				{
					string value = GetValue(TNSdesc, ref num2);
					if (!string.IsNullOrEmpty(value) && !int.TryParse(value, out connectionOption.m_portNumber))
					{
						throw new NetworkException(12545);
					}
				}
				if (num2 < TNSdesc.Length && TNSdesc[num2] == '/')
				{
					connectionOption.ServiceName = GetValue(TNSdesc, ref num2);
					if (num2 < TNSdesc.Length)
					{
						if (TNSdesc[num2] == ':')
						{
							connectionOption.Server = GetValue(TNSdesc, ref num2);
						}
						if (num2 < TNSdesc.Length && TNSdesc[num2] == '/')
						{
							connectionOption.InstanceName = GetValue(TNSdesc, ref num2);
						}
					}
				}
			}
			if (connectionOption.Port == -1)
			{
				connectionOption.Port = 1521;
			}
			if (connectionOption.ServiceName == null && m_SNOConfig.HostnameDefaultServiceIsHost)
			{
				connectionOption.ServiceName = connectionOption.Host;
			}
			connectionOption.Address = new StringBuilder().Append(BEG_ADDR).Append(connectionOption.Protocol).Append(BEG_HOST)
				.Append(connectionOption.Host)
				.Append(BEG_PORT)
				.Append(connectionOption.Port)
				.Append(END_TWO_BRACES)
				.ToString();
			StringBuilder stringBuilder = ((connectionOption.ServiceName == null) ? new StringBuilder().Append(BEG_CONDATA) : new StringBuilder().Append(BEG_CONDATA_SVC).Append(connectionOption.ServiceName).Append(END_ONE_BRACE));
			if (connectionOption.Server != null)
			{
				stringBuilder = stringBuilder.Append(BEG_SRVR).Append(connectionOption.Server).Append(END_ONE_BRACE);
			}
			if (m_instanceName != null)
			{
				stringBuilder = stringBuilder.Append(BEG_INST).Append(m_instanceName).Append(END_ONE_BRACE);
			}
			else if (connectionOption.InstanceName != null)
			{
				stringBuilder = stringBuilder.Append(BEG_INST).Append(connectionOption.InstanceName).Append(END_ONE_BRACE);
			}
			if (ful_CID != null)
			{
				stringBuilder = stringBuilder.Append(ful_CID);
			}
			connectionOption.ConnectData = new StringBuilder().Append(BEG_DESC).Append(connectionOption.Address).Append(stringBuilder)
				.Append(END_TWO_BRACES)
				.ToString();
			return connectionOption;
		}

		private ConnectionOption ResolveAddr(string TNSdesc)
		{
			new ConnectionOption();
			if (TNSdesc.StartsWith(ALIAS))
			{
				string text = TNSdesc;
				TNSdesc = text.Substring(text.IndexOf(ALIAS) + 6, text.Length - (text.IndexOf(ALIAS) + 6));
			}
			NVPair nvp = NVFactory.CreateNVPair(TNSdesc);
			NVNavigator.FindNVPairRecurse(nvp, DESCRIPTION_LIST);
			if (m_dlist != null)
			{
				m_desc = NVNavigator.FindNVPair(m_dlist, DESCRIPTION);
			}
			else
			{
				m_desc = NVNavigator.FindNVPairRecurse(nvp, DESCRIPTION);
			}
			return BuildCO(addr: (m_desc == null) ? NVNavigator.FindNVPairRecurse(nvp, ADDRESS) : NVNavigator.FindNVPair(m_desc, ADDRESS), desc: m_desc, addAddrToDesc: false);
		}

		internal void BuildCO_Redirect(string cndr, ref ConnectionOption co)
		{
			if (cndr == null)
			{
				throw new NetworkException(12533);
			}
			NVPair nVPair = NVFactory.CreateNVPair(cndr);
			NVPair addr = ((!(nVPair.Name.ToUpperInvariant() == DESCRIPTION)) ? nVPair : NVNavigator.FindNVPair(nVPair, ADDRESS));
			BuildCO_Addr(addr, ref co);
		}

		internal void BuildCO_Addr(NVPair addr, ref ConnectionOption co)
		{
			NVPair nVPair = NVNavigator.FindNVPair(addr, PROTOCOL);
			if (nVPair == null)
			{
				throw new NetworkException(12533);
			}
			co.Protocol = nVPair.Atom;
			if (!string.Equals(co.Protocol, DEFAULT_CONNECT_PROTOCOL, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(co.Protocol, SSL_CONNECT_PROTOCOL, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(co.Protocol, WEBSOCK_CONNECT_PROTOCOL, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(co.Protocol, WEBSOCK_SECURE_CONNECT_PROTOCOL, StringComparison.InvariantCultureIgnoreCase))
			{
				throw new NetworkException(12533);
			}
			nVPair = NVNavigator.FindNVPair(addr, HOST);
			if (nVPair == null || nVPair.Atom == null)
			{
				co.Host = "";
			}
			else
			{
				co.Host = nVPair.Atom;
			}
			nVPair = NVNavigator.FindNVPair(addr, PORT);
			if (nVPair == null || nVPair.Atom == null)
			{
				co.Port = 0;
			}
			else
			{
				co.Port = int.Parse(nVPair.Atom);
			}
			nVPair = NVNavigator.FindNVPair(addr, IP);
			if (nVPair == null || nVPair.Atom == null)
			{
				co.IP = null;
			}
			else
			{
				co.IP = nVPair.Atom;
			}
			if ((nVPair = NVNavigator.FindNVPair(addr, SBS)) == null)
			{
				nVPair = NVNavigator.FindNVPair(addr, SendBufSize);
			}
			if (nVPair != null && nVPair.Atom != null)
			{
				int num2 = (co.SBS = int.Parse(nVPair.Atom));
				if (num2 <= 0)
				{
					co.SBS = 0;
				}
			}
			if ((nVPair = NVNavigator.FindNVPair(addr, RBS)) == null)
			{
				nVPair = NVNavigator.FindNVPair(addr, RecvBufSize);
			}
			if (nVPair != null && nVPair.Atom != null)
			{
				int num2 = (co.RBS = int.Parse(nVPair.Atom));
				if (num2 <= 0)
				{
					co.RBS = 0;
				}
			}
			if ((nVPair = NVNavigator.FindNVPair(addr, HTTPS_PROXY)) != null)
			{
				if (string.IsNullOrEmpty(co.Host))
				{
					throw new NetworkException(12533);
				}
				co.HTTPS_PROXY = nVPair.Atom.Trim();
				if ((nVPair = NVNavigator.FindNVPair(addr, HTTPS_PROXY_PORT)) != null)
				{
					co.HTTPS_PROXY_PORT = int.Parse(nVPair.Atom);
				}
			}
			if ((nVPair = NVNavigator.FindNVPair(addr, WEBSOCK_URI)) != null)
			{
				co.WEBSOCK_URI = nVPair.Atom.Trim();
			}
		}

		internal static int ConvExpTimetoMilli(string TO)
		{
			try
			{
				int result = 0;
				Match match = new Regex("(?<Numeric>[-+]*[0-9]*)(?<Alpha>[a-zA-Z]*)").Match(TO);
				string value = match.Groups["Alpha"].Value;
				int num = int.Parse(match.Groups["Numeric"].Value);
				if (num < 0)
				{
					return -1;
				}
				switch (value)
				{
				case "":
					result = num * 60000;
					break;
				case "min":
					result = num * 60000;
					break;
				case "ms":
					result = num;
					break;
				case "cs":
					result = num * 10;
					break;
				case "ds":
					result = num * 100;
					break;
				case "sec":
					result = num * 1000;
					break;
				case "das":
					result = num * 10000;
					break;
				case "hs":
					result = num * 100000;
					break;
				case "ks":
					result = num * 1000000;
					break;
				}
				return result;
			}
			catch (Exception)
			{
				return 0;
			}
		}

		internal static int TOConvert2Milli(string TO)
		{
			int num = 0;
			if (string.IsNullOrEmpty(TO))
			{
				return 60000;
			}
			Match match = new Regex("(?<Numeric>[-+]*[0-9]*)(?<Alpha>[a-zA-Z]*)").Match(TO);
			string value = match.Groups["Alpha"].Value;
			int num2 = int.Parse(match.Groups["Numeric"].Value);
			if (num2 < 0)
			{
				return -1;
			}
			switch (value)
			{
			case "":
				num = 1000;
				break;
			case "ms":
				num = 1;
				break;
			case "cs":
				num = 10;
				break;
			case "ds":
				num = 100;
				break;
			case "sec":
				num = 1000;
				break;
			case "min":
				num = 60000;
				break;
			case "das":
				num = 10000;
				break;
			case "hs":
				num = 100000;
				break;
			case "ks":
				num = 1000000;
				break;
			}
			return num2 * num;
		}

		private ConnectionOption BuildCO(NVPair desc, NVPair addr, bool addAddrToDesc = true)
		{
			ConnectionOption co = new ConnectionOption();
			NVPair nVPair2;
			if (desc != null)
			{
				NVPair nVPair = NVNavigator.FindNVPair(desc, SECURITY);
				if (nVPair != null)
				{
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, SSL_VERSION)) != null)
					{
						co.SSL_Version = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, WALLETDIR)) != null)
					{
						co.SSL_WALLET_DIRECTORY = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, WALLETLOC)) != null)
					{
						co.SSL_WALLET_DIRECTORY = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, SSLServerDN)) != null)
					{
						co.SSLServerDN = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, SSLServerDNMatch)) != null)
					{
						co.SSLServerDNMatching = SqlNetOraConfig.ParamValueIsTrue(nVPair2.Atom);
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, EncryptionClient)) != null)
					{
						co.Encryption = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, EncryptionTypesClient)) != null)
					{
						co.EncryptionTypes = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, CryptoChecksumClient)) != null)
					{
						co.CryptoChecksum = nVPair2.Atom;
					}
					if ((nVPair2 = NVNavigator.FindNVPair(nVPair, CryptoChecksumTypesClient)) != null)
					{
						co.CryptoChecksumTypes = nVPair2.Atom;
					}
				}
				string input = (((nVPair2 = NVNavigator.FindNVPair(desc, TRANSPORT_CONNECT_TO)) == null) ? m_SNOConfig.TCPCTimeOut : nVPair2.Atom);
				input = Regex.Replace(input, "\\s+", "");
				co.TransportConnectTO = TOConvert2Milli(input);
			}
			if ((nVPair2 = NVNavigator.FindNVPair(desc, SBS)) == null)
			{
				nVPair2 = NVNavigator.FindNVPair(desc, SendBufSize);
			}
			int sBS;
			if (nVPair2 != null && nVPair2.Atom != null && (sBS = int.Parse(nVPair2.Atom)) > 0)
			{
				co.SBS = sBS;
			}
			if ((nVPair2 = NVNavigator.FindNVPair(desc, RBS)) == null)
			{
				nVPair2 = NVNavigator.FindNVPair(desc, RecvBufSize);
			}
			if (nVPair2 != null && nVPair2.Atom != null && (sBS = int.Parse(nVPair2.Atom)) > 0)
			{
				co.RBS = sBS;
			}
			BuildCO_Addr(addr, ref co);
			nVPair2 = NVNavigator.FindNVPair(desc, SDU);
			if (nVPair2 != null)
			{
				sBS = int.Parse(nVPair2.Atom);
				if (sBS > 0 && sBS >= ConnectionOption.NSPMNSDULN)
				{
					if (sBS > ConnectionOption.NSPMXSDULN)
					{
						sBS = ConnectionOption.NSPMXSDULN;
					}
					co.SessionDataUnitSize = sBS;
				}
			}
			nVPair2 = NVNavigator.FindNVPair(desc, TDU);
			if (nVPair2 != null)
			{
				sBS = int.Parse(nVPair2.Atom);
				if (sBS > 0 && sBS >= ConnectionOption.NSPMNTDULN)
				{
					if (sBS > ConnectionOption.NSPMXTDULN)
					{
						sBS = ConnectionOption.NSPMXTDULN;
					}
					co.TransportDataUnitSize = sBS;
				}
			}
			addInstance(desc, co);
			if (addAddrToDesc)
			{
				int pos = desc.AddListElementI(addr);
				co.ConnectData = desc.ToString();
				desc.RemoveListElement(pos);
			}
			else
			{
				co.ConnectData = desc.ToString();
			}
			co.Address = new StringBuilder().Append(BEG_ADDR).Append(DEFAULT_CONNECT_PROTOCOL).Append(BEG_HOST)
				.Append(co.Host)
				.Append(BEG_PORT)
				.Append(co.Port)
				.Append(END_TWO_BRACES)
				.ToString();
			return co;
		}
	}
}
